<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html">



    <head>
    </head>

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">

                <h:panelGroup rendered="#{!(webUserController.hasPrivilege('LabAutherizing') eq true or webUserController.hasPrivilege('LabDataentry') eq true or webUserController.hasPrivilege('LabPrinting') eq true)}" >
                    You are NOT authorized
                </h:panelGroup>

                <h:form id="form">



                    <p:commandButton styleClass="nonPrintBlock" ajax="false" value="Print" onclick="window.print();" actionListener="#{patientReportController.printPatientReport()}" />
<!--                    <p:commandButton styleClass="nonPrintBlock" ajax="false" value="PDF" 
                                     action="#{patientReportController.createPDF()}" onclick="this.form.target = '_blank'" />-->
                    <!--<p:commandButton styleClass="nonPrintBlock" ajax="false" value="Back" action="/lab/search_for_reporting_ondemand"/>-->




                    <p:panel styleClass="myDivToPrint" id="divPrint" style="background-color: white!important; border: 0px; margin: 0px; padding: 0px;" >



                        <h:panelGroup rendered="#{patientReportController.currentPatientReport.item.reportType ne 'Microbiology'}"  >
                            <div id="divReport"  style="min-width:800px;min-height: 1100px; position: relative; font-size: 120%;">



                                <ui:repeat value="#{commonReportItemController.items}" var="myCli" >
                                    <div style="#{myCli.cssStyle}; position:absolute;">
                                        <h:outputText rendered="#{myCli.ixItemType eq 'Label' and myCli.retired ne true }"  value="#{myCli.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'PatientName' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.patient.person.nameWithTitle}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'PatientAge' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.patient.age}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'PatientSex' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.patient.person.sex}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'InvestigationName' and  myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.investigation.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'Speciman' and  myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.investigation.sample.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'SampledTime' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.sampledAt}" style="color: #{myCli.cssColor}" escape="false" >

                                            <f:convertDateTime pattern="hh mm ss a"/>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'CollectingCenter' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.collectingCentre}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'BilledDate' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.createdAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="dd MM yyyy"></f:convertDateTime>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'BilledTime' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.createdAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="hh mm ss a"/>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'SampledDate' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.sampledAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="dd MM yyyy"></f:convertDateTime>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'BillNo' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.insId}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>

                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReportedDate' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.createdAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="dd MM yyyy"></f:convertDateTime>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReportedTime' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.createdAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="hh mm ss a"/>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReferringDoctor' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.referredBy.person.nameWithTitle}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReferringInstitution' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.referredByInstitution.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>

                                        <p:graphicImage rendered="#{myCli.reportItemType eq 'AutherizedSignature' and myCli.retired eq false and patientReportController.currentPatientReport.approveUser.staff.id ne null }"    value="#{staffImageController.signatureById}" style="width: #{myCli.cssWidth}; max-height: 50px!important;"  >
                                            <f:param name="id" value="#{patientReportController.currentPatientReport.approveUser.staff.id}" />
                                        </p:graphicImage>

                                    </div>
                                </ui:repeat>


                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >

                                    <div style="#{prv.investigationItem.cssStyle}; position:absolute;">
                                        <h:outputLabel value="#{prv.lobValue}" rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Memo' and prv.investigationItem.retired eq false}"  escape="false" />
                                    </div>
                                </ui:repeat>

                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >
                                    <div style="#{prv.investigationItem.cssStyle}; position:absolute;">
                                        <h:outputLabel value="#{prv.strValue}" rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Varchar'}" escape="false" />
                                    </div>
                                </ui:repeat>

                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >
                                    <div style="#{prv.investigationItem.cssStyle}; position:absolute;">
                                        <h:outputLabel value="#{prv.doubleValue}"  rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Double' and prv.investigationItem.retired eq false}"   escape="false" />
                                    </div>
                                </ui:repeat>


                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >
                                    <div style="#{prv.investigationItem.cssStyle}; position:absolute;">
                                        <h:outputLabel value="#{prv.strValue}" rendered="#{prv.investigationItem.ixItemType eq 'DynamicLabel'}" escape="false" />
                                    </div>
                                </ui:repeat>

                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >
                                    <div style="#{prv.investigationItem.cssStyle}; position:absolute;">
                                        <h:outputLabel value="#{prv.strValue}" rendered="#{prv.investigationItem.ixItemType eq 'Flag'}" escape="false" />
                                    </div>
                                </ui:repeat>

                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >
                                    <div style="#{prv.investigationItem.cssStyle}; position:absolute;">
                                        <h:outputLabel value="#{prv.doubleValue}" rendered="#{prv.investigationItem.ixItemType eq 'Calculation' }" escape="false" >
                                            <f:convertNumber pattern="0.0" />
                                        </h:outputLabel>
                                    </div>
                                </ui:repeat>

                                <ui:repeat value="#{patientReportController.currentPatientReport.item.reportItems}" var="myIi" >
                                    <div style="#{myIi.cssStyle}; position:absolute;">
                                        <h:outputText rendered="#{myIi.retired ne true and myIi.ixItemType eq 'Label' }" value="#{myIi.htmltext}" style="color: #{myIi.cssColor}" escape="false" ></h:outputText>
                                    </div>
                                </ui:repeat>


                            </div>
                        </h:panelGroup>


                        <h:panelGroup rendered="#{patientReportController.currentPatientReport.item.reportType eq 'Microbiology'}"  >
                            <div id="divReportM"  style="min-width:800px;min-height: 1100px; position: relative; font-size: 150%;">
                                <ui:repeat value="#{commonReportItemController.items}" var="myCli" >
                                    <div style="#{myCli.cssStyle}; position:absolute;">
                                        <h:outputText rendered="#{myCli.ixItemType eq 'Label' and myCli.retired ne true }"  value="#{myCli.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'PatientName' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.patient.person.nameWithTitle}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'PatientAge' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.patient.age}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'PatientSex' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.patient.person.sex}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'InvestigationName' and  myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.investigation.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'Speciman' and  myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.investigation.sample.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'SampledTime' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.sampledAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="hh mm ss a"/>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'BilledDate' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.createdAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="dd MM yyyy"></f:convertDateTime>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'BilledTime' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.createdAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="hh mm ss a"/>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'SampledDate' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.sampledAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="dd MM yyyy"></f:convertDateTime>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'BillNo' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.insId}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>

                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReportedDate' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.dataEntryAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="dd MM yyyy"></f:convertDateTime>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReportedTime' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.dataEntryAt}" style="color: #{myCli.cssColor}" escape="false" >
                                            <f:convertDateTime pattern="hh mm ss a"/>
                                        </h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReferringDoctor' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.referredBy.person.nameWithTitle}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>
                                        <h:outputText rendered="#{myCli.ixItemType ne 'Label' and myCli.reportItemType eq 'ReferringInstitution' and myCli.retired eq false }"  value="#{patientReportController.currentPatientReport.patientInvestigation.billItem.bill.referredByInstitution.name}" style="color: #{myCli.cssColor}" escape="false" ></h:outputText>

                                        <h:panelGroup rendered="#{patientReportController.currentPatientReport.approveUser.staff.baImage ne null}">
                                            <p:graphicImage rendered="#{myCli.reportItemType eq 'AutherizedSignature' and myCli.retired eq false }"    value="#{staffImageController.signatureById}" style="width: #{myCli.cssWidth}; max-height: 50px!important;"  >
                                                <f:param name="id" value="#{patientReportController.currentPatientReport.approveUser.staff.id}" />
                                            </p:graphicImage>


                                        </h:panelGroup>

                                    </div>
                                </ui:repeat>



                                <table id="micro" style="position: absolute; top: 35%; left:10%; font-size: 14px!important;" >
                                    <tr>
                                        <td>
                                            <h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                           #{patientReportController.currentPatientReport.patientInvestigation.investigation.printName}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" 
                                                           style="font-weight: bold;font-size: 16px!important; margin: 5px;padding: 5px; border: solid black 1px;"/>
                                        </td>
                                    </tr>
                                    <tr><td><h:outputLabel/></td></tr>
                                    <tr><td><h:outputLabel/></td></tr>
                                    <tr><td><h:outputLabel/></td></tr>
                                    <tr>
                                        <td id="micromemos">
                                            <table  style="width: 100%!important;">                 
                                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >

                                                    <h:panelGroup rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Memo' and prv.investigationItem.retired eq false and prv.lobValue ne '' and prv.lobValue ne null and prv.investigationItem.riTop  lt 50 }" >
                                                        <tr >
                                                            <td style="min-width: 250px; vertical-align: top;">
                                                                <br/>
                                                                <h:outputLabel value="#{prv.investigationItem.name}"  escape="false"  />
                                                            </td>
                                                            <td>
                                                                <h:outputLabel value="#{prv.lobValue}"  escape="false" style="white-space: pre-wrap;" />
                                                            </td>
                                                        </tr>
                                                    </h:panelGroup>

                                                    <h:panelGroup rendered="#{prv.investigationItem.ixItemType eq 'DynamicLabel' and prv.investigationItem.retired eq false and prv.investigationItem.riTop  lt 50 }" >
                                                        <tr >
                                                            <td style="min-width: 250px;">
                                                                <h:outputLabel value="#{prv.investigationItem.name}"  escape="false"  />
                                                            </td>
                                                            <td>

                                                            </td>
                                                        </tr>
                                                    </h:panelGroup>



                                                </ui:repeat>
                                            </table>
                                        </td>
                                    </tr>
                                    <br/><br/>




                                    <tr>
                                        <td id="micLabelsBeforeAbst">

                                            <ui:repeat value="#{patientReportController.currentPatientReport.item.reportItems}" var="myMicIi" >
                                                <div style="#{myMicIi.cssStyle}; left: #{prvl.cssLeft};">
                                                    <h:outputText rendered="#{myMicIi.retired ne true and myMicIi.ixItemType eq 'List' }" 
                                                                  value="#{myMicIi.name}" style="color: #{myMicIi.cssColor}" escape="false" ></h:outputText>
                                                </div>
                                            </ui:repeat>


                                        </td>
                                    </tr>

                                    <tr>
                                        <td id="ablist">
                                            <table>
                                                <tr>
                                                    <td colspan="2"  >
                                                        <h:outputLabel 
                                                            value="Antibiotic Sensitivity Test"
                                                            rendered="#{patientReportController.currentPatientReport.transHasAbst}"
                                                            style="font-size: 120%!important;font-weight: bold;"></h:outputLabel>
                                                    </td>
                                                </tr>
                                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" 
                                                            var="prv" >
                                                    <h:panelGroup 
                                                        rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Varchar' and prv.investigationItem.retired eq false and prv.strValue ne '' and prv.strValue ne null  }" >
                                                        <tr>
                                                            <td style="min-width: 250px;">
                                                                <h:outputLabel value="#{prv.investigationItem.name}"  escape="false" />
                                                            </td>
                                                            <td>

                                                                <h:outputLabel value="#{prv.strValue}" escape="false" />
                                                            </td>
                                                        </tr>
                                                    </h:panelGroup>
                                                </ui:repeat>
                                            </table>

                                        </td>
                                    </tr>
                                    <br/><br/>
                                    <tr>
                                        <td id="miccomments">
                                            <table>
                                                <ui:repeat  value="#{patientReportController.currentPatientReport.patientReportItemValues}" var="prv" >
                                                    <h:panelGroup rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Memo' and prv.investigationItem.retired eq false and prv.lobValue ne '' and prv.lobValue ne null and prv.investigationItem.riTop gt 50 }" >

                                                        <tr>
                                                            <td style="min-width: 250px;padding: 5px;padding-left: 1px; padding-right: 1px;">
                                                                <h:outputLabel value="#{prv.investigationItem.name}"  escape="false" />
                                                            </td>
                                                            <td>
                                                                <h:outputLabel value="#{prv.lobValue}"  escape="false" />
                                                            </td>
                                                        </tr>

                                                    </h:panelGroup>

                                                </ui:repeat>
                                            </table>

                                        </td>
                                    </tr>

                                </table>


                            </div>
                        </h:panelGroup>




                    </p:panel>


                </h:form>


            </ui:define>



        </ui:composition>

    </h:body>
</html>
